<?php

namespace Modules\Edu\System;


use App\Models\WeChat;
use App\Models\WeChatRule;
use Houdunren\WeChat\Message;
use Illuminate\Support\Facades\Log;
use Modules\Edu\Entities\System;

class Processor
{
    public function handle(WeChatRule $rule, Message $message, WeChat $model)
    {
        //@options 模块下的模型ID和模型名称
        switch ($rule->options['type']) {
            case 'system':
                $lesson = System::find($rule->options['id']);

                return $message->news(
                    [
                        [
                            'title' => $lesson['title'],
                            'description' => $lesson['description'],
                            'picurl' => $lesson['preview'],
                            'url' => route('edu.front.system.show', $lesson)
                        ],
                    ]
                );

        }
    }
}
